function drawProfiles() {
	$('.button.profil').remove();
	$(".leek.enemy").each(function(index, data) {
		drawProfile($(data));
	});
	$('#farmers .farmer').each(function(index, data) {
		drawProfileFarmer($(data));
	});
}

function drawProfile(leek) {
	var leekId = leek.attr('id');
	
	leek.parent().append('<a class="button profil profil-' + leekId + '" href="http://leekwars.com/leek/' + leekId + '">Profil</a>');
	
	var button = $('.profil-' + leekId);
	button.css('left', leek.position().left + (leek.width() - button.width()) / 2);
}

function drawProfileFarmer(farmer) {
	var farmerId = farmer.attr('id');
	
	farmer.parent().append('<a class="button profil profil-' + farmerId + '" href="http://leekwars.com/farmer/' + farmerId + '">Profil</a>');
	
	var button = $('.profil-' + farmerId);
	button.css('left', farmer.position().left + (farmer.width() - button.width()) / 2);
}

if (document.URL == "http://leekwars.com/garden") {
	$('#garden-solo h2').last().css('margin-bottom', '30px');
	$('#garden-farmer h2').first().css('margin-bottom', '30px');
	drawProfiles();
	
	$('#enemies .myleek').click(function() {
		drawProfiles();
	});
	
	$('#garden-left div').click(function() {
		drawProfiles();
	});

	$(".enemyCompo").each(function(index) {
		var compo = $(this);
		var name = compo.children()[1].nextSibling.data;
		
		name = "Sutat";
		
	});
} 
